package com.grj.order.service;

import com.grj.common.model.Order;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Service;

@Service
public class OrderProducer {
    private final KafkaTemplate<String, Object> kafkaTemplate;
    private final String topic = "order-created";

    public OrderProducer(KafkaTemplate<String, Object> kafkaTemplate) {
        this.kafkaTemplate = kafkaTemplate;
    }

    public void sendOrderCreated(Order order) {
        kafkaTemplate.send(topic, order.getOrderId(), order);
        System.out.println("📤 [OrderService] Sent order-created: " + order.getOrderId());
    }
}
